package com.kaigejava.springwebsocket.controller;

import com.alibaba.fastjson.JSON;
import com.kaigejava.springwebsocket.domain.Items;

import com.kaigejava.springwebsocket.service.IitemsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("item")
@Slf4j
public class ItemController {

    @Autowired
    private IitemsService itemsService;
    @RequestMapping("{id}/show")
    public String showDetailById(Model model,@PathVariable("id") Integer id){
        Items items = itemsService.getInfoById(id);
        log.info("====items:{}", JSON.toJSON(items));
        model.addAttribute("item",items);
        return  "/item/show";
    }

}
